package com.loan.web.api;

import com.loan.entity.RepaymentMethod;
import com.loan.entity.ResponseResult;
import com.loan.exception.RepaymentMethodException;
import com.loan.service.RepaymentMethodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: RepaymentMethodController
 * @Author: wYin
 * @Date: 2022/1/19 17:25
 */
@RestController
@SuppressWarnings("all")
@RequestMapping("/api/repaymentMethod")
public class RepaymentMethodController {
    @Autowired
    private RepaymentMethodService repaymentMethodService;

    /**
     * @Desc: 得到所有的还款方式的数据
     * @Param: []
     * @Return: com.loan.entity.ResponseResult<java.util.List<com.loan.entity.RepaymentMethod>>
     * @Author: wYin
     * @Date: 2022/1/19 17:40
     */
    @GetMapping("/getAll")
    public ResponseResult<List<RepaymentMethod>> getAll(){
        List<RepaymentMethod> list = repaymentMethodService.list();
        if(list.size()==0){
            throw new RepaymentMethodException("网络错误，没有查询到还款方式");
        }
        return new ResponseResult<>(list);
    }
}
